
//1.引用http模块

const http = require("http");

//2.创建服务器

const serve = http.createServer((req,res)=>{
    res.writeHead(200,{'Context-Type':'text/html'});
    res.write('<head><meta charset="utf-8"/></head>'); 
    let msg = {
        code:200,
        data:[
            {name:"张三"},
            {name:"11"},
            {name:"22"},
            {name:"22"},
            {name:"33"}
        ]
    }
    msg = JSON.stringify(msg)
    res.end(msg)
})

serve.listen(8080)


console.log("服务器已经启动")